package alan.springboot2x.sharejdbc.module.order.service.impl;

import alan.springboot2x.sharejdbc.module.order.entity.TOrder;
import alan.springboot2x.sharejdbc.module.order.mapper.TOrderMapper;
import alan.springboot2x.sharejdbc.module.order.service.ITOrderService;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单表 服务实现类
 * </p>
 *
 * @author alan
 * @since 2021-03-03
 */
@Service
@Slf4j
public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements ITOrderService {

    @Override
    public List<TOrder> getByUserId(Long userId) {
        return new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getUserId,userId).list();
    }

    @Override
    public List<TOrder> getByUserIdAndOrderId(Long userId, Long orderId) {
        return new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getUserId,userId).eq(TOrder::getOrderId,orderId).list();
    }

    @Override
    public List<TOrder> getByOrderId(Long orderid) {
//        try {
//            Thread.sleep(200);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        List<TOrder> list1 = new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId, orderid).list();
        List<TOrder> list2 = new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,orderid).list();
        List<TOrder> list3 = new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,orderid).list();
        List<TOrder> list4 = new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,orderid).list();
        log.info("orderid_1:{} list4:{}",orderid,list4);
        list4 = new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,orderid+1).list();
        list4 = new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,orderid+2).list();
        list4 = new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,orderid+3).list();
        list4 = new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,orderid+4).list();
        list4 = new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,orderid+5).list();
        list4 = new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,orderid+6).list();
        list4 = new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,orderid+7).list();
        log.info("orderid_2:{} list4:{}",orderid + 1,list4);

        return new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,orderid).list();
    }
}
